package com.zzl.bonds.ticket.controller;

import com.zzl.apidoc.annotation.ApidocController;
import com.zzl.apidoc.annotation.ApidocOperation;
import com.zzl.apidoc.annotation.ApidocParam;
import com.zzl.bonds.ticket.dto.TickecirculationRecordAddDto;
import com.zzl.bonds.ticket.dto.TickecirculationRecordUpdateDto;
import com.zzl.bonds.ticket.entity.TickecirCulationRecordEntity;
import com.zzl.bonds.ticket.service.TicketCirculationRecordService;
import com.zzl.general.common.apidoc.annotation.ApidocParamsPage;
import com.zzl.general.common.apidoc.annotation.ApidocResultKeyValR;
import com.zzl.general.common.apidoc.annotation.ApidocReturnPage;
import com.zzl.general.common.apidoc.annotation.ApidocReturnR;
import com.zzl.general.common.apidoc.constants.ResultTypeInR;
import com.zzl.general.common.ctrl.WebBaseCtrl;
import com.zzl.general.common.exception.SysException;
import com.zzl.general.common.utils.LogUtils;
import com.zzl.general.common.utils.PageUtils;
import com.zzl.general.common.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;
/**
 * 统计开立 转让 融资成功的 金额
 *
 * @author sunpp
 * @date 2022-02-16 14:04:05
 */
@ApidocController("统计开立 转让 融资成功的 金额")
@RestController
@SuppressWarnings("javadoc")
@RequestMapping("bondsticket/tickecirculationrecord")
@Slf4j
public class TicketCirculationRecordController extends WebBaseCtrl {
    @SuppressWarnings("all")
    @Autowired
    private TicketCirculationRecordService ticketCirculationRecordService;

    /**
     * 列表
     */
    @GetMapping("/list")
    @ApidocOperation(description = "分页查询统计开立 转让 融资成功的 金额数据", operationId = "/ticket/tickecirculationrecord/list")
    @ApidocReturnPage(genericTypeClass = TickecirCulationRecordEntity.class)
    public Result list(@ApidocParamsPage(name = "params") @RequestParam Map<String, Object> params){
        PageUtils page = ticketCirculationRecordService.queryPage(params);
        return Result.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    @ApidocOperation(description = "通过id获取统计开立 转让 融资成功的 金额数据",operationId = "/ticket/tickecirculationrecord/info")
    @ApidocReturnR(otherkv = {
            @ApidocResultKeyValR(resultType = ResultTypeInR.TYPE_OBJECT, key = "tickecirculationRecord", valueClass = TickecirCulationRecordEntity.class)
    })
    public Result info(@ApidocParam(name = "统计开立 转让 融资成功的 金额id", required = true) @PathVariable("id") String id){
		TickecirCulationRecordEntity tickecirculationRecord = ticketCirculationRecordService.getById(id);
        return Result.ok().put("tickecirculationRecord", tickecirculationRecord);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    @ApidocOperation(description = "保存统计开立 转让 融资成功的 金额",operationId = "/ticket/tickecirculationrecord/save")
    @ApidocReturnR
    public Result save(@ApidocParam(name = "保存的统计开立 转让 融资成功的 金额对象值", required = true) @RequestBody TickecirculationRecordAddDto tickecirculationRecord){
        try {
            ticketCirculationRecordService.saveTickecirculationRecord(tickecirculationRecord, this.getUser());
            return Result.ok();
        } catch (SysException e) {
            LogUtils.logSysException(log, e);
            return Result.error(e.getMsg());
        }
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    @ApidocOperation(description = "修改统计开立 转让 融资成功的 金额",operationId = "/ticket/tickecirculationrecord/update")
    @ApidocReturnR
    public Result update(@ApidocParam(name = "修改的统计开立 转让 融资成功的 金额对象值", required = true) @RequestBody TickecirculationRecordUpdateDto tickecirculationRecord){
        try {
            ticketCirculationRecordService.updateTickecirculationRecordById(tickecirculationRecord, this.getUser());
            return Result.ok();
        } catch (SysException e) {
            LogUtils.logSysException(log, e);
            return Result.error(e.getMsg());
        }
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    @ApidocOperation(description = "删除统计开立 转让 融资成功的 金额",operationId = "/ticket/tickecirculationrecord/delete")
    @ApidocReturnR
    public Result delete(@ApidocParam(name = "删除的统计开立 转让 融资成功的 金额对象id集合", required = true) @RequestBody String[] ids){
		ticketCirculationRecordService.removeByIds(Arrays.asList(ids));
        return Result.ok();
    }

}
